//
//  HZGoodsCuxiaoCellView.m
//  app
//
//  Created by 刘华舟 on 15/5/26.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZGoodsCuxiaoCellView.h"

static const NSInteger kCommonLabelHeight = 40/2;
static const CGFloat kViewPadding = 6/2.0f;



@implementation HZGoodsCuxiaoCellView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.frame = CGRectOf([self.ufo fx:UB_LEFT fy:UB_TOP],[self.ubo uw:HZGoodsCuxiaoCellViewWidth oh:HZGoodsCuxiaoCellViewHeight]);
        //选择标记
        
        self.backgroundColor = HZ_WHITE_COLOR;
        
        self.selectBtn = [[UIButton alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT fy:UB_TOP oy:(HZGoodsCuxiaoCellViewHeight-kCommonLabelHeight)/2],
                                                                      [self.ubo ow:kCommonLabelHeight oh:kCommonLabelHeight])];
   
        
        [self.selectBtn setImage:[UIImage imageNamed:kImageMallCartGoodUnselect] forState:UIControlStateNormal];
        [self.selectBtn setImage:[UIImage imageNamed:kImageMallCartGoodSelected] forState:UIControlStateSelected];
        self.selectBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        [self.selectBtn addTarget:self action:@selector(selectBtnOnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.selectBtn];
        

        
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.selectBtn.ubo fx:UB_RIGHT ox:kViewPadding fy:UB_TOP oy:(HZGoodsCuxiaoCellViewHeight-kCommonLabelHeight)/2],
                                                                 [self.ubo fw:UB_WIDTH ow:self.selectBtn.ufo.yy-kViewPadding oh:kCommonLabelHeight])];
        
        self.titleLabel.font = kHZFont_Content_S;
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.textColor = HZ_MALL_TEXT_L_LIGHTGRAY_COLOR;
        self.titleLabel.userInteractionEnabled = YES;
        UITapGestureRecognizer *tapGestr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleBtnOnClick:)];
        [self.titleLabel addGestureRecognizer:tapGestr];
        [self addSubview:self.titleLabel];
        
    }
    return self;
}



- (void)selectBtnOnClick:(UIButton *)btn{
    if (self.itemSelectTaretCaller) {
        [self.itemSelectTaretCaller call:self];
    }
}

- (void)titleBtnOnClick:(UIButton *)btn{
    if (self.itemSelectTaretCaller) {
        [self.itemSelectTaretCaller call:self];
    }
}

@end
